package com.yixuan.mt.common.mapper;

import com.yixuan.mt.common.entity.Policy;
import com.yixuan.mt.common.request.PostPoliciesRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PoliciesMapper {

    @Insert("insert into policies (name, content) values(#{name}, #{content})")
    void insertPolicy(PostPoliciesRequest postPoliciesRequest);

    @Delete("delete from policies where id = #{id}")
    void deletePolicy(Integer id);

    @Update("update policies set content = #{content} where id = #{id}")
    void updatePolicy(Policy policy);

    @Select("select id, name from policies")
    List<Policy> selectPoliciesList();

    List<Policy> selectPoliciesListByIds(Integer[] ids);

    @Select("select count(*) from policies where name = #{name}")
    boolean selectIsExistByName(String name);

    @Select("select content from policies where id = #{id}")
    String selectPolicyDetail(Integer id);
}
